"""
1.增加策略模板母类
2.增加嵌套策略功能，定义为mini ss
"""
class ss_base:
    def __init__(self,config,pos):
        self.config=config
        self.pos=pos
        self.mini_ss=[]
    def add_mini_ss(self,miniss):
        self.mini_ss.append(miniss)
    def ontick(self,d):
        for i in self.mini_ss:
            if not i.isstop:
                i.ontick(d)
    def on1mbar(self,d):
        delminiss=[]
        for i in self.mini_ss:
            i.on1mbar(d)
            if i.isstop:
                delminiss.append(i)
        for i in delminiss:
            self.mini_ss.remove(i)
    def onbeforeopen(self,d):
        for i in self.mini_ss:
            i.onbeforeopen(d)
    def onbeforeclose(self,d):
        delminiss = []
        for i in self.mini_ss:
            i.onbeforeclose(d)
            if i.isstop:
                delminiss.append(i)
        for i in delminiss:
            self.mini_ss.remove(i)
    def onendday(self,d):
        delminiss = []
        for i in self.mini_ss:
            i.onendday(d)
            if i.isstop:
                delminiss.append(i)
        for i in delminiss:
            self.mini_ss.remove(i)

